home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / gtlayout_defines.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-18  |  13.6 KB  |  646 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #ifndef _GTLAYOUT_DEFINES_H
  8. #define _GTLAYOUT_DEFINES_H 1
  9.  
  10.     // Keyboard qualifiers
  11.  
  12. #define QUALIFIER_SHIFT     (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)
  13. #define QUALIFIER_ALT        (IEQUALIFIER_LALT | IEQUALIFIER_RALT)
  14. #define QUALIFIER_CONTROL    (IEQUALIFIER_CONTROL)
  15.  
  16.  
  17. /*****************************************************************************/
  18.  
  19.  
  20.     // Undefine these to remove various chunks of support from this code
  21.  
  22. #ifdef LIB_CODE
  23. #define DO_PASSWORD_KIND
  24. #define DO_FRACTION_KIND
  25. #define DO_GAUGE_KIND
  26. #define DO_TAPEDECK_KIND
  27. #define DO_HEXHOOK
  28. #define DO_PICKSHORTCUTS
  29. #define DO_CLONING
  30. #define DO_LEVEL_KIND
  31. #else
  32. #define DO_PASSWORD_KIND
  33. //#define DO_FRACTION_KIND
  34. #define DO_GAUGE_KIND
  35. //#define DO_HEXHOOK
  36. #define DO_PICKSHORTCUTS
  37. #define DO_CLONING
  38. #define DO_TAPEDECK_KIND
  39. #endif    /* LIB_CODE */
  40.  
  41.  
  42. /*****************************************************************************/
  43.  
  44.  
  45.     // Stuff from amiga.lib that we want to declare stdargs/regargs
  46.  
  47. VOID __regargs    NewList(struct MinList *list);
  48. VOID __regargs    TimeDelay(LONG unit,ULONG secs,ULONG micros);
  49. ULONG __regargs DoSuperMethodA(struct IClass *cl, Object *obj, Msg message);
  50. APTR __asm    AsmCreatePool(register __d0 ULONG MemFlags,register __d1 ULONG PuddleSize,register __d2 ULONG ThreshSize,register __a6 struct ExecBase *SysBase);
  51. VOID __asm    AsmDeletePool(register __a0 APTR PoolHeader,register __a6 struct ExecBase *SysBase);
  52. APTR __asm    AsmAllocPooled(register __a0 APTR PoolHeader, register __d0 ULONG Size,register __a6 struct ExecBase *SysBase);
  53. VOID __asm    AsmFreePooled(register __a0 APTR PoolHeader,register __a1 APTR Memory,register __d0 ULONG MemSize,register __a6 struct ExecBase *SysBase);
  54.  
  55. VOID __stdargs    kprintf(STRPTR,...);
  56.  
  57. #define BOOLSTRING(w) ((w) ? "TRUE" : "FALSE")
  58.  
  59.  
  60. /*****************************************************************************/
  61.  
  62.  
  63.     // Scan an Exec list
  64.  
  65. #define SCANLIST(l,n)    for(n = (APTR)((struct MinList *)l) -> mlh_Head; \
  66.             ((struct MinNode *)n) -> mln_Succ; \
  67.             n = (APTR)((struct MinNode *)n) -> mln_Succ)
  68.  
  69.     // Scan the objects of a group
  70.  
  71. #define SCANGROUP(g,n)    for(n = (APTR)g -> Special . Group . ObjectList . mlh_Head; \
  72.             ((struct MinNode *)n) -> mln_Succ; \
  73.             n = (APTR)((struct MinNode *)n) -> mln_Succ)
  74.  
  75.     // Scan the objects of a group, only allowing active pages
  76.  
  77. #define SCANPAGE(g,n,p) for(p = 0, n = (APTR)g -> Special . Group . ObjectList . mlh_Head; \
  78.             ((struct MinNode *)n) -> mln_Succ; \
  79.             n = (APTR)((struct MinNode *)n) -> mln_Succ) \
  80.             if ((p++ == g -> Special . Group . ActivePage) || !g -> Special . Group . Paging)
  81.  
  82.     // Get an object pointer from a gadget pointer
  83.  
  84. #define GETOBJECT(g,n)    ((n = (ObjectNode *)g -> UserData) && (n -> Host == g) && (n -> PointBack == n))
  85.  
  86.  
  87. /*****************************************************************************/
  88.  
  89.  
  90. #ifdef DO_PASSWORD_KIND
  91. #define TEST_PASSWORD_KIND(n) || (n -> Type == PASSWORD_KIND)
  92. #else
  93. #define TEST_PASSWORD_KIND(n) || (FALSE)
  94. #endif
  95.  
  96. #ifdef DO_FRACTION_KIND
  97. #define TEST_FRACTION_KIND(n) || (n -> Type == FRACTION_KIND)
  98. #else
  99. #define TEST_FRACTION_KIND(n) || (FALSE)
  100. #endif
  101.  
  102.     // Is an object derived from STRING_KIND?
  103.  
  104. #define LIKE_STRING_KIND(n)    ((n -> Type == STRING_KIND) TEST_PASSWORD_KIND(n) TEST_FRACTION_KIND(n))
  105.  
  106.  
  107. /*****************************************************************************/
  108.  
  109.  
  110. typedef UBYTE BOOLEAN;
  111.  
  112. #define INCREMENTER_KIND    42
  113. #define PICKER_KIND        43
  114. #define GROUP_KIND        44
  115.  
  116. #define LAPR_Gadget        TAG_USER+100
  117. #define LAPR_Object        TAG_USER+101
  118.  
  119. typedef struct GaugeExtra
  120. {
  121.     LONG             InfoLength;
  122.     STRPTR             InfoText;
  123. } GaugeExtra;
  124.  
  125. typedef struct TapeDeckExtra
  126. {
  127.     struct Image        *ButtonImage;
  128.     LONG             ButtonWidth,
  129.                  ButtonHeight;
  130.     BOOLEAN          ButtonType,
  131.                  Toggle,
  132.                  Pressed,
  133.                  Smaller;
  134. } TapeDeckExtra;
  135.  
  136. typedef struct ButtonExtra
  137. {
  138.     BOOLEAN          ReturnKey;
  139.     BOOLEAN          EscKey;
  140.     BOOLEAN          ExtraFat;
  141. } ButtonExtra;
  142.  
  143. typedef struct BarExtra
  144. {
  145.     struct ObjectNode    *Parent;
  146.     BOOLEAN          FullSize;
  147. } BarExtra;
  148.  
  149. typedef struct BoxExtra
  150. {
  151.     struct ObjectNode    *Parent;
  152.     STRPTR            *Labels;
  153.     STRPTR            *Lines;
  154.     BYTE             AlignText;
  155.     WORD             MaxSize;
  156.     BOOLEAN          DrawBox;
  157.     BOOLEAN          ReserveSpace;
  158. } BoxExtra;
  159.  
  160. typedef struct FrameExtra
  161. {
  162.     UWORD             InnerWidth;
  163.     UWORD             InnerHeight;
  164.     struct Hook        *RefreshHook;
  165.     BOOLEAN          DrawBox;
  166. } FrameExtra;
  167.  
  168. typedef struct PickerExtra
  169. {
  170.     struct Gadget        *Parent;
  171.     struct Image        *Image;
  172. } PickerExtra;
  173.  
  174. typedef struct IncrementerExtra
  175. {
  176.     struct Gadget        *Parent;
  177.     struct Image        *Image;
  178.     LONG             Amount;
  179. } IncrementerExtra;
  180.  
  181. typedef struct GroupExtra
  182. {
  183.     struct MinList         ObjectList;
  184.     struct ObjectNode    *ParentGroup;
  185.     UWORD             ExtraLeft;
  186.     UWORD             ExtraTop;
  187.     LONG             MaxOffset;
  188.     LONG             MaxSize;
  189.     ULONG             ActivePage;
  190.     BOOLEAN          Horizontal;
  191.     BOOLEAN          Paging;
  192.     BOOLEAN          Spread;
  193.     BOOLEAN          SameSize;
  194.     BOOLEAN          LastAttributes;
  195.     BOOLEAN          Visible;
  196.     BOOLEAN             Frame;
  197. } GroupExtra;
  198.  
  199. typedef struct ListExtra
  200. {
  201.     struct List        *Labels;
  202.     struct Gadget        *Link;
  203.     LONG             LinkID;
  204.     struct Hook        *CallBack;
  205.     STRPTR            *ExtraLabels;
  206.     UWORD             ExtraLabelWidth;
  207.     UWORD             MaxPen;
  208.     UWORD             MaxGrowX,MaxGrowY;
  209.     UWORD             MinChars,MinLines;
  210.     BOOLEAN          ReadOnly;
  211.     BOOLEAN          CursorKey;
  212.     BOOLEAN          AllocatedList;
  213.     BOOLEAN             LockSize;
  214.     BOOLEAN             SizeLocked;
  215.     BOOLEAN             ResizeX;
  216.     BOOLEAN             ResizeY;
  217.     BOOLEAN             FlushLabelLeft;
  218.     BOOLEAN             IgnoreListContents;
  219. } ListExtra;
  220.  
  221. typedef struct RadioExtra
  222. {
  223.     STRPTR            *Choices;
  224.     UWORD             LabelWidth;
  225.     UBYTE             TitlePlace;
  226.     LONG             AutoPageID;
  227.     BOOLEAN             TabKey;
  228. } RadioExtra;
  229.  
  230. typedef struct TextExtra
  231. {
  232.     STRPTR             Text;
  233.     struct Gadget        *Picker;
  234.     UWORD             Len;
  235.     BOOLEAN          Border;
  236.     BOOLEAN          CopyText;
  237.     BOOLEAN          UsePicker;
  238.     UBYTE             Justification;
  239. } TextExtra;
  240.  
  241. typedef struct NumberExtra
  242. {
  243.     LONG             Number;
  244.     BOOLEAN          Border;
  245.     UBYTE             Justification;
  246. } NumberExtra;
  247.  
  248. typedef struct CycleExtra
  249. {
  250.     STRPTR            *Choices;
  251.     LONG             AutoPageID;
  252.     BOOLEAN             TabKey;
  253. } CycleExtra;
  254.  
  255. typedef struct PalExtra
  256. {
  257.     UBYTE            *ColourTable;
  258.     UBYTE            *TranslateBack;
  259.     UWORD             Depth;
  260.     UWORD             NumColours;
  261.     BOOLEAN          SmallPalette;
  262. } PalExtra;
  263.  
  264. typedef struct SliderExtra
  265. {
  266.     STRPTR             LevelFormat;
  267.     DISPFUNC         DispFunc;
  268.     LONG             MaxLevelLen;
  269.     LONG             LevelWidth;
  270.     STRPTR             OriginalLabel;
  271.     UBYTE             LevelPlace;
  272.     BOOLEAN          FullLevelCheck;
  273. } SliderExtra;
  274.  
  275. typedef struct StringExtra
  276. {
  277.     struct LayoutHandle    *LayoutHandle;
  278.     struct Hook        *HistoryHook;
  279.     ULONG             MaxHistoryLines;
  280.     ULONG             NumHistoryLines;
  281.     struct Node        *CurrentNode;
  282.  
  283.     STRPTR             String;
  284.     LONG             MaxChars;
  285.     struct Hook        *EditHook;
  286.     struct Gadget        *Picker;
  287.     STRPTR             Backup;
  288.     STRPTR             RealString;
  289.     STRPTR             Original;
  290.     LONG             LinkID;
  291.     UBYTE             Justification;
  292.     BOOLEAN          LastGadget;
  293.     BOOLEAN          UsePicker;
  294. } StringExtra;
  295.  
  296. typedef struct IntegerExtra
  297. {
  298.     struct LayoutHandle    *LayoutHandle;
  299.     struct Hook        *HistoryHook;
  300.     ULONG             MaxHistoryLines;
  301.     ULONG             NumHistoryLines;
  302.     struct Node        *CurrentNode;
  303.  
  304.     LONG             Number;
  305.     LONG             MaxChars;
  306.     struct Hook        *EditHook;
  307.     UBYTE             Justification;
  308.     BOOLEAN          LastGadget;
  309.     BOOLEAN          UseIncrementers;
  310.  
  311.     struct Gadget        *LeftIncrementer;
  312.     struct Gadget        *RightIncrementer;
  313.  
  314.     struct Hook        *IncrementerHook;
  315. } IntegerExtra;
  316.  
  317. typedef struct ScrollerExtra
  318. {
  319.     WORD             Visible,
  320.                  ArrowSize;
  321.     BOOLEAN          RelVerify,
  322.                  Immediate,
  323.                  Arrows,
  324.                  Vertical,
  325.                  Thin;
  326. } ScrollerExtra;
  327.  
  328. typedef struct LevelExtra
  329. {
  330.     struct LayoutHandle    *Handle;
  331.     LONG             Min,
  332.                  Max,
  333.                  Level,
  334.                  Plus;
  335.     STRPTR             LevelFormat;
  336.     struct Image        *LevelImage;
  337.     DISPFUNC         DispFunc;
  338.     struct Hook         CustomHook;
  339.     LONG             MaxLevelWidth,
  340.                  MidOffset,
  341.                  LevelPlace;
  342.     BOOL             FullLevelCheck;
  343. } LevelExtra;
  344.  
  345. typedef struct ObjectNode
  346. {
  347.     struct MinNode         Node;
  348.     struct Gadget        *Host;
  349.     struct ObjectNode    *PointBack;
  350.     STRPTR             Label;
  351.     LONG             ID;
  352.     UBYTE             Type;
  353.     BYTE             LabelPlace;
  354.     BOOLEAN          Disabled;
  355.     BYTE             ObjectPlace;
  356.     LONG             Min;
  357.     LONG             Max;
  358.     LONG             Current;
  359.     UWORD             Left;
  360.     UWORD             Top;
  361.     UWORD             Width;
  362.     UWORD             Height;
  363.     UWORD             LabelWidth;
  364.     UWORD             Lines;
  365.     UWORD             Chars;
  366.     WORD             ExtraSpace;
  367.     BOOLEAN          NoKey;
  368.     BOOLEAN          HighLabel;
  369.     BOOLEAN          GroupIndent;
  370.     BOOLEAN          PageSelector;
  371.     UBYTE             Key;
  372.     UBYTE             StorageType;
  373.     WORD             LabelChars;
  374.     APTR             Storage;
  375.  
  376.     union
  377.     {
  378.         GaugeExtra        Gauge;
  379.         TapeDeckExtra        TapeDeck;
  380.         ButtonExtra        Button;
  381.         BarExtra        Bar;
  382.         BoxExtra        Box;
  383.         FrameExtra        Frame;
  384.         PickerExtra        Picker;
  385.         IncrementerExtra    Incrementer;
  386.         GroupExtra        Group;
  387.         ListExtra        List;
  388.         RadioExtra        Radio;
  389.         TextExtra        Text;
  390.         NumberExtra        Number;
  391.         CycleExtra        Cycle;
  392.         PalExtra        Palette;
  393.         SliderExtra        Slider;
  394.         StringExtra        String;
  395.         IntegerExtra        Integer;
  396.         ScrollerExtra        Scroller;
  397.         LevelExtra        Level;
  398.     } Special;
  399. } ObjectNode;
  400.  
  401. typedef struct LayoutHandle
  402. {
  403.         // WARNING: Beginning of this structure must match the definition in gui.h!
  404.  
  405.     struct Screen        *Screen;
  406.     struct DrawInfo     *DrawInfo;
  407.     struct Window        *Window;
  408.     APTR             VisualInfo;
  409.     struct Image        *AmigaGlyph,
  410.                 *CheckGlyph;
  411.     APTR             UserData;
  412.  
  413.     struct Screen        *PubScreen;
  414.     struct MsgPort        *MsgPort;
  415.     struct Gadget        **GadgetArray;
  416.     struct Gadget        *Previous;
  417.     struct Gadget        *List;
  418.     ULONG             IDCMP;
  419.  
  420.     ObjectNode        *ActiveIncrementer;
  421.     LONG             IncrementerCountdown;
  422.  
  423.         // Cached from DrawInfo structure
  424.  
  425.     UWORD             TextPen;
  426.     UWORD             BackgroundPen;
  427.     UWORD             ShadowPen;
  428.     UWORD             ShinePen;
  429.     UWORD             AspectX;
  430.     UWORD             AspectY;
  431.  
  432.     ULONG             ClickSeconds;
  433.     ULONG             ClickMicros;
  434.     ObjectNode        *ClickObject;
  435.  
  436.     struct Hook        *LocaleHook;
  437.     struct TextAttr     *TextAttr;
  438.     struct TextAttr     *InitialTextAttr;
  439.     struct TTextAttr     CopyTextAttr;
  440.     struct RastPort      RPort;
  441.     APTR             Pool;
  442.     UWORD             GlyphWidth;
  443.     UWORD             InterWidth;
  444.     UWORD             InterHeight;
  445.     LONG             Count;
  446.     LONG             Index;
  447.     LONG             MaxID;
  448.     ObjectNode        *TopGroup;
  449.     ObjectNode        *CurrentGroup;
  450.     ObjectNode        *EscKey;
  451.     ObjectNode        *ReturnKey;
  452.     ObjectNode        *CursorKey;
  453.     ObjectNode        *GrowView;
  454.     ObjectNode        *ResizeView;
  455.     ObjectNode        *TabKey;
  456. #ifdef DO_FRACTION_KIND
  457.     struct Hook         FracEditHook;
  458. #endif
  459. #ifdef DO_PASSWORD_KIND
  460.     struct Hook         PasswordEditHook;
  461. #endif
  462. #ifdef DO_HEXHOOK
  463.     struct Hook         HexEditHook;
  464. #endif
  465.     struct Hook         DefaultEditHook;
  466.     struct Hook        *StandardEditHook;
  467.     struct Hook         BackfillHook;
  468.  
  469. #ifdef DO_PICKSHORTCUTS
  470.     UBYTE             Keys[256];
  471. #endif
  472.  
  473.     struct Hook        *HelpHook;        // Hook to call when help key is pressed
  474.     LONG             MaxPen;
  475.  
  476.     BOOLEAN          AutoRefresh;
  477.     BOOLEAN          CloseFont;
  478.     BOOLEAN          Failed;
  479.     BOOLEAN          Rescaled;
  480.     BOOLEAN          AutoActivate;
  481.     BOOLEAN          MoveToWindow;
  482.  
  483. #ifdef DO_CLONING
  484.     BOOLEAN          CloningPermitted;    // Genetic engineering?
  485.     BOOLEAN          ExactClone;        // Make an exact copy, i.e. preserve all colours
  486.     BOOL             SimpleClone;        // Just a simple clone, please
  487.     struct CloneExtra    *CloneExtra;        // Screen cloning information
  488. #endif
  489.  
  490.     struct Window        *Parent;        // Parent of this window
  491.     BOOLEAN             BlockParent;
  492.     BOOLEAN             Expand;
  493.     BOOLEAN             ExitFlush;
  494.  
  495.     BOOLEAN             SizeVerified;
  496.     WORD             SizeWidth,
  497.                  SizeHeight;
  498.  
  499. #ifdef DO_LEVEL_KIND
  500.     ObjectNode        *CurrentLevel;
  501. #endif    /* DO_LEVEL_KIND */
  502. } LayoutHandle;
  503.  
  504.  
  505. /*****************************************************************************/
  506.  
  507.  
  508.     // Window locking
  509.  
  510. typedef struct LockNode
  511. {
  512.     struct MinNode         MinNode;
  513.     struct Window        *Window;
  514.     LONG             Count;
  515.     ULONG             OldIDCMPFlags;
  516.     struct Requester     Requester;
  517.     LONG             MinWidth;
  518.     LONG             MinHeight;
  519.     LONG             MaxWidth;
  520.     LONG             MaxHeight;
  521. } LockNode;
  522.  
  523.  
  524. /*****************************************************************************/
  525.  
  526.  
  527.     // Image class extension
  528.  
  529. typedef struct ImageInfo
  530. {
  531.     UWORD             ImageType,    // Type
  532.  
  533.                  GlyphWidth,    // Size
  534.                  GlyphHeight,
  535.  
  536.                  Pad;        // Pad to long
  537. } ImageInfo;
  538.  
  539.     // Image class extension types
  540.  
  541. #define IIA_ImageType    (TAG_USER+739)
  542. #define IIA_GlyphWidth    (TAG_USER+740)
  543. #define IIA_GlyphHeight (TAG_USER+741)
  544.  
  545.     // Supported image class extension types
  546.  
  547. typedef enum ImageTypes
  548. {
  549.     IMAGECLASS_PICKER,
  550.     IMAGECLASS_LEFTINCREMENTER,
  551.     IMAGECLASS_RIGHTINCREMENTER,
  552.     IMAGECLASS_BACKWARD,
  553.     IMAGECLASS_FORWARD,
  554.     IMAGECLASS_PREVIOUS,
  555.     IMAGECLASS_NEXT,
  556.     IMAGECLASS_RECORD,
  557.     IMAGECLASS_PLAY,
  558.     IMAGECLASS_STOP,
  559.     IMAGECLASS_PAUSE,
  560.     IMAGECLASS_REWIND,
  561.     IMAGECLASS_EJECT
  562. } ImageTypes;
  563.  
  564.  
  565. /*****************************************************************************/
  566.  
  567.  
  568.     // Level image class
  569.  
  570. typedef struct LevelImageInfo
  571. {
  572.     WORD         KnobWidth,    // Width of knob (actually half of it)
  573.              KnobTop,    // Distance from knob to level body
  574.              LevelHeight;    // Height of level body
  575.  
  576.     LONG         Position,    // Position of knob on level body
  577.              Max,        // Maximum value
  578.              Current;    // Current value
  579.  
  580.     struct DrawInfo *DrawInfo;    // Handy
  581. } LevelImageInfo;
  582.  
  583.     // Level class control tags
  584.  
  585. #define LVIA_Current    (TAG_USER+0xF000)    // Current value
  586. #define LVIA_Max    (TAG_USER+0xF001)    // Maximum value
  587. #define LVIA_DrawInfo    (TAG_USER+0xF002)    // Pens, etc.
  588. #define LVIA_Position    (TAG_USER+0xF003)    // Position of knob
  589. #define LVIA_KnobWidth    (TAG_USER+0xF004)    // Width of knob
  590. #define LVIA_FontWidth    (TAG_USER+0xF005)    // Reference font width
  591.  
  592.  
  593. /*****************************************************************************/
  594.  
  595.  
  596. typedef enum StorageTypes
  597. {
  598.     STORAGE_BYTE,STORAGE_UBYTE,
  599.     STORAGE_WORD,STORAGE_UWORD,
  600.     STORAGE_LONG,STORAGE_ULONG,
  601.     STORAGE_STRPTR
  602. } StorageTypes;
  603.  
  604.  
  605. /*****************************************************************************/
  606.  
  607.  
  608.     // A single colour in 96 bit precision
  609.  
  610. struct ColourTriplet
  611. {
  612.     ULONG            Red,        // 32 bits each
  613.                 Green,
  614.                 Blue;
  615. };
  616.  
  617.     // A colour table ready to submit to LoadRGB32
  618.  
  619. struct ColourRecord
  620. {
  621.     UWORD            NumColours,    // Number of colours in this chunk
  622.                 FirstColour;    // First colour entry to set
  623.  
  624.     struct ColourTriplet    Triplets[0];    // Table entries
  625.  
  626.     WORD            Arnold;     // Array terminator, needs to be set to zero
  627. };
  628.  
  629.     // Screen reproduction
  630.  
  631. struct CloneExtra
  632. {
  633.     struct Screen        *Screen;
  634.     LONG            *Pens;
  635.     UWORD            *ScreenPens;
  636.     UWORD             MinWidth,
  637.                  MinHeight,
  638.                  MaxWidth,
  639.                  MaxHeight,
  640.                  TotalPens;
  641.     UBYTE             Depth;
  642.     struct IBox         Bounds;
  643. };
  644.  
  645. #endif
  646.